#include "line.h"
#include <QApplication>
#include <QPainter>
#include <iostream>
using namespace std; 

Lines::Lines(QWidget *parent)
    : QWidget(parent)
{

}

void Lines::paintEvent(QPaintEvent *event)
{

  QPen pen(Qt::black, 2, Qt::SolidLine);

  QPainter painter(this);

  painter.setPen(pen);
//  painter.drawLine(0, 40, 400, 40);

  for (unsigned i = 0 ; i < polygons.size(); ++i)
  {
	  for (unsigned j = 0; j < polygons[i].size()  ; j +=2 )
	  {
		  painter.drawLine ( unsigned(this->polygons[i][j] * 400), 
							 unsigned (this->polygons[i][j+1] *400), 
							 unsigned(this->polygons[i][(j+2) % polygons[i].size()] * 400), 
							 unsigned (this->polygons[i][(j+3)%polygons[i].size()] * 400 ));
	  }
  }

}
